<?php
header('Content-type:text/json');
require('KDPay.php');
$kdPay = new KDPay('1000017', '3b0662bcf067474cbab62f971c0112ad');
/***********
 * 以下为查询操作
 */
$order_id = $_GET['order'];
$channelId = $_GET['channel'];
$faveValue = $_GET['money'];
$card_id = $_GET['card'];

$query_url = $kdPay->queryOrderUrl($order_id, $channelId, $faveValue, $card_id);
$result = curl_post($query_url);
parse_str($result,$result_arr);

$flag = $result_arr['P_flag'];
$status = $result_arr['P_status'];

echo json_encode(array("flag"=>$flag,"status"=>$status));


/***************************
 * 以下为所需函数
 *
 */

function curl_post($url)
{

    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $output = curl_exec($ch);

    curl_close($ch);
    return $output;
}